
    var map = new BMap.Map('point',{minZoom:13,maxZoom:18,enableMapClick:false});
    map.centerAndZoom(new BMap.Point(116.404, 39.915),6);
    map.enableScrollWheelZoom();
    map.disableDoubleClickZoom();
    var point = "/Map/searchPointDate",//行政区数据接口
        estateDate = "/Map/estateDate",
        markerClusterer,
        flag,
        allAreaResult;
    //请求接口
    function clusterDate (url,zone_number) {
        $.ajax({
            type: "post",
            url: url,
            data:zone_number,
            async: false,
            success:function (data) {
                allAreaResult = data.result;
            }
        })
    };
    function search(){
    //清空搜索
    $("#search").val("");
    $('#searchCommunity').html("");
    $('#searchCommunity').css('display','none');
    $('#district').val("");
    $('#risk').val("");
    $("#s2id_risk span:first").html("押品风险");
    $('#startDateStart').val("");
    $('#startDateEnd').val("");
    $('#buildArea').val("");
    $("#s2id_buildArea span:first").html("面积区段");
    $('#loansDuration').val("");
    $("#s2id_loansDuration span:first").html("抵押年限");
    // var s = $("#select2-chosen-1").text();
    // city.search(s); //查找城市
    var zoneNumber = $("#city").val();
    var cityName = $("#city").find("option:selected").text();
    //清除地图覆盖物
    map.clearOverlays();
    if((!zoneNumber || zoneNumber=="-1") && (!cityName || cityName=="请选择城市")){
        map.centerAndZoom(new BMap.Point(116.404, 39.915),12);
        return;
    }
    map.centerAndZoom(cityName);
    map.enableScrollWheelZoom(); // 允许滚轮缩放
    var zoneNumber = {city: zoneNumber};
    createPoint(point,zoneNumber);
}
    function createPoint (zoneNumber) {
        clusterDate(point,zoneNumber);
        var pt = null;
        var markers = [];
        var i = 0;
        for (; i < allAreaResult.length; i++) {
            if (allAreaResult[i].lng && allAreaResult[i].lat) {
                pt = new BMap.Point(allAreaResult[i].lng, allAreaResult[i].lat);
                markers.push(new BMap.Marker(pt));
            }

        }
        markerClusterer = new BMapLib.MarkerClusterer(map, {markers:markers});
    }
    map.addEventListener("zoomend",scrollFunc);
    //监听地图层级
    function scrollFunc (e) {
        e=e || window.event;
        var zoneNumber = $("#city").val();
        var zoneNumber = {city: zoneNumber};
        var zoom = map.getZoom();
        if(zoom == 17 || zoom == 18){
            map.clearOverlays();
            getBuilding(point);
        }else if (flag){
            map.clearOverlays();
            createPoint(point,zoneNumber);
            flag = false;
        }
    }
    //地图17 || 18的时候渲染自定义楼栋
    function getBuilding (point) {
        var zoneNumber = $("#city").val();
        markerClusterer.clearMarkers();
        flag = true;
        //console.log(markerClusterer);
        //map.clearOverlays();
        //BMapLib.MarkerClusterer.clearMarkers();
        //markerClusterer.removeMarkers(markers);
        var bs = map.getBounds();   //获取可视区域
        var bssw = bs.getSouthWest();   //可视区域左下角
        var bsne = bs.getNorthEast();   //可视区域右上角
        var bsswLeft = bssw.lng + "," + bssw.lat;
        var bsneRight = bsne.lng + "," + bsne.lat;
        var zoneNumber = {city: zoneNumber,leftTop: bsswLeft,rightUp: bsneRight};
        clusterDate(point,zoneNumber);
        allAreaResult.forEach(function (searchEstate) {
                //自定义楼栋覆盖物
                function ComplexCustomOverlay(point,num){
                    this._point = point;
                    this._num = num;
                }
                ComplexCustomOverlay.prototype = new BMap.Overlay();
                ComplexCustomOverlay.prototype.initialize = function(map){
                    this._map = map;
                    var div = this._div = document.createElement("div");
                    div.style.position = "absolute";
                    div.style.zIndex = "-1";
                    div.style.backgroundColor = "#26b095";
                    div.style.color = "white";
                    div.style.height = "30px";
                    div.style.lineHeight = "18px";
                    div.style.opacity = '0.9';
                    div.style.textAlign = "center";
                    div.style.borderRadius = "4px";
                    div.style.whiteSpace = "nowrap";
                    div.style.MozUserSelect = "none";
                    div.style.fontSize = "12px";
                    div.style.cursor = "pointer";
                    div.style.padding = "6px";
                    div.appendChild(document.createTextNode(this._num));
                    var sj = this._p = document.createElement("p");
                    sj.style.position = "absolute";
                    //sj.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
                    sj.style.width = 0;
                    sj.style.height = 0;
                    sj.style.borderTop = "10px solid #26b095";
                    sj.style.borderLeft = "10px solid transparent";
                    sj.style.borderRight = "10px solid transparent";
                    sj.style.bottom = "-20px";
                    sj.style.left = "25%";
                    div.appendChild(sj);
                    div.onmouseenter = function(){
                        this.style.backgroundColor = "#e84a01";
                        sj.style.borderTop = "10px solid #e84a01";
                    };
                    div.onmouseleave = function(){
                        this.style.backgroundColor = "#26b095";
                        sj.style.borderTop = "10px solid #26b095";
                    };
                    var o = 0;
                    var ul = document.createElement("div");
                    div.onclick = function () {
                        o++;
                        //console.log($(this).siblings("div").children("div.hpanel").length);
                        $(this).siblings("div").children("div.hpanel").css("display","none");
                        div.style.zIndex = "auto";
                        $(this).siblings("div").css("zIndex","-10");
                        var zone_number = {lng:searchEstate.lng,lat:searchEstate.lat};
                        clusterDate(estateDate,zone_number);
                        if(o == 1){
                            ul.className = "hpanel";
                            ul.style.position = "absolute";
                            ul.style.top = "0";
                            ul.style.display = "block";
                            var body = document.createElement("div");
                            body.className = "panel-body list";
                            body.style.overflowY = "scroll";
                            var container = document.createElement("div");
                            container.className = "list-item-container";
                            container.style.maxHeight = "200px";
                            div.appendChild(ul);
                            body.appendChild(container);
                            ul.appendChild(body);
                            allAreaResult.forEach(function(data){
                                var item = document.createElement("div");
                                item.className = "list-item";
                                item.style.overflowX = "inherit";
                                var h3 = document.createElement("h3");
                                h3.className = "no-margins font-extra-bold text-success";
                                h3.style.fontSize = "12px";
                                if(data.cltv > 60 && data.cltv <= 80){
                                    h3.style.color = "#FF9800";
                                }else if(data.cltv > 80 && data.cltv <= 100){
                                    h3.style.color = "#E51C23";
                                }else if(data.cltv >= 100){
                                    h3.style.color = "#8B1818";
                                }
                                h3.appendChild(document.createTextNode(data.sourceAddress));
                                item.appendChild(h3);
                                container.appendChild(item);
                                item.onclick = function () {
                                    var href = window.location.origin + "/estate/mapShow/" + data.id;
                                    window.open(href);
                                };
                            });
                            ul.style.left = div.offsetWidth + "px";
                        }else if(ul.style.display == "block"){
                            ul.style.display = "none";
                        }else{
                            ul.style.display = "block"
                        }
                        ul.onmouseenter = function () {
                            disableScroll(map);
                        };
                        ul.onmouseleave = function () {
                            endisableScroll(map);
                        };
                    };
                    map.getPanes().labelPane.appendChild(div);
                    return div;
                };
                ComplexCustomOverlay.prototype.draw = function(){
                    var map = this._map;
                    var pixel = map.pointToOverlayPixel(this._point);
                    this._div.style.left = pixel.x + "px";
                    this._div.style.top  = pixel.y + "px";
                };
                var pt = new BMap.Point(searchEstate.lng,searchEstate.lat);
                var areaResult = searchEstate.count + "笔";
                myCompOverlay = new ComplexCustomOverlay(pt, areaResult);
                map.addOverlay(myCompOverlay);
            });
    }
